﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using VIBlend.WPF.Controls;

namespace AnonsaiWPF.CSharp.Buttons
{
    public partial class CheckBoxDemo : Window, IWindow
    {
        VIBlend.WPF.Controls.CheckBox selectedCheckBox;
        
        public CheckBoxDemo()
        {
            InitializeComponent();
            selectedCheckBox = this.checkBox1;
         }

        public void DetachContent()
        {
            RemoveLogicalChild(Content);
        }

        public void SetTheme()
        {
        }

        public Grid Root
        {
            get
            {
                return this.RootVisual;
            }
        }


        private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.comboBox1 == null)
                return;

            switch (comboBox1.SelectedIndex)
            {
                case 0:
                    this.selectedCheckBox = this.checkBox1;
                    break;
                case 1:
                    this.selectedCheckBox = this.checkBox2;
                    break;
                case 2:
                    this.selectedCheckBox = this.checkBox3;
                    break;
            }
        }

        private void comboBox2_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.comboBox2 == null)
                return;

            if (this.selectedCheckBox == null)
                return;

            switch (comboBox2.SelectedIndex)
            {
                case 0:
                    this.selectedCheckBox.CheckAlignment = AnchorStyles.Left;
                    if (this.selectedCheckBox.ContentPresenter != null)
                    {
                        this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left;
                        this.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
                    }

                    if (this.selectedCheckBox.Check != null)
                    {
                        this.selectedCheckBox.Check.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                        this.selectedCheckBox.Check.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    }

                    break;
                case 1:
                    this.selectedCheckBox.CheckAlignment = AnchorStyles.Right;
                    if (this.selectedCheckBox.ContentPresenter != null)
                    {
                        this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right;
                        this.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
                    }

                    if (this.selectedCheckBox.Check != null)
                    {
                        this.selectedCheckBox.Check.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                        this.selectedCheckBox.Check.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    }
                    break;
                case 2:
                    this.selectedCheckBox.CheckAlignment = AnchorStyles.Top;
                    if (this.selectedCheckBox.ContentPresenter != null)
                    {
                        this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
                        this.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
                    }

                    if (this.selectedCheckBox.Check != null)
                    {
                        this.selectedCheckBox.Check.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                        this.selectedCheckBox.Check.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    }

                    break;
                case 3:
                    this.selectedCheckBox.CheckAlignment = AnchorStyles.Bottom;
                    if (this.selectedCheckBox.ContentPresenter != null)
                    {
                        this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
                        this.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
                    }

                    if (this.selectedCheckBox.Check != null)
                    {
                        this.selectedCheckBox.Check.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                        this.selectedCheckBox.Check.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    }

                    break;
            }
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (this.selectedCheckBox != null)
            {
                this.selectedCheckBox.Toggle();
            }
        }

        private void checkBox4_Checked(object sender, RoutedEventArgs e)
        {
            this.checkBox1.IsRadioGroupEnabled = true;
            this.checkBox2.IsRadioGroupEnabled = true;
            this.checkBox3.IsRadioGroupEnabled = true;
        }

        private void checkBox4_Unchecked(object sender, RoutedEventArgs e)
        {
            this.checkBox1.IsRadioGroupEnabled = false;
            this.checkBox2.IsRadioGroupEnabled = false;
            this.checkBox3.IsRadioGroupEnabled = false;
        }

        private void comboBox6_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.selectedCheckBox == null)
                return;

            switch (this.comboBox6.SelectedIndex)
            {
                case 0:
                    this.selectedCheckBox.CheckMarkBrushHighlight = new SolidColorBrush(Color.FromArgb(255, 27, 41, 62));
                    break;
                case 1:
                    this.selectedCheckBox.CheckMarkBrushHighlight = new SolidColorBrush(Colors.Blue);
                    break;
                case 2:
                    this.selectedCheckBox.CheckMarkBrushHighlight = new SolidColorBrush(Colors.Red);
                    break;
                case 3:
                    this.selectedCheckBox.CheckMarkBrushHighlight = new SolidColorBrush(Color.FromArgb(255, 4, 34, 113));
                    break;
                case 4:
                    this.selectedCheckBox.CheckMarkBrushHighlight = new SolidColorBrush(Colors.Green);
                    break;
                case 5:
                    break;
            }
        }

        private void comboBox7_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.selectedCheckBox == null)
                return;

            switch (this.comboBox7.SelectedIndex)
            {
                case 0:
                    this.selectedCheckBox.CheckMarkBrushPressed = new SolidColorBrush(Colors.Black);
                    break;
                case 1:
                    this.selectedCheckBox.CheckMarkBrushPressed = new SolidColorBrush(Colors.Blue);
                    break;
                case 2:
                    this.selectedCheckBox.CheckMarkBrushPressed = new SolidColorBrush(Colors.Red);
                    break;
                case 3:
                    this.selectedCheckBox.CheckMarkBrushPressed = new SolidColorBrush(Color.FromArgb(255, 4, 34, 113));
                    break;
                case 4:
                    this.selectedCheckBox.CheckMarkBrushPressed = new SolidColorBrush(Colors.Green);
                    break;
                case 5:
                    break;
            }
        }
    }
}
